﻿using UnityEngine;
using System.Collections;

namespace IMIForUnity
{
    public class ImiPreferences
    {
        private static ImiPreferences instance = null;

        public ImiResolution colorResolution;
        public ImiResolution depthResolution;
        
        //Depth, Skeleton, Depth + Skeleton, User Depth + Skeleton
        public bool DepthStream;
        public bool SkeletonStream;
        public bool DepthSkeletonStream;
        public bool UserDepthAndSkeletonStream;
        //Color Stream
        public bool ColorStream;

        /// <summary>
        /// 只显示深度图
        /// </summary>
        public bool showDepthOnly;
        /// <summary>
        /// 是否绘制所有人的图像
        /// </summary>
        public bool showAllUsersColor;
        /// <summary>
        /// 是否绘制主控玩家图像
        /// </summary>
        public bool showMainUserColor;
        /// <summary>
        /// 是否绘制次要玩家图像
        /// </summary>
        public bool showSubUserColor;

        /// <summary>
        /// 是否绘制所有人的前景图.
        /// </summary>
        public bool showAllUsersDepth;
        /// <summary>
        /// 是否绘制主控玩家的前景图.
        /// </summary>
        public bool showMainUserDepth;
        /// <summary>
        /// 是否绘制副控玩家的前景图.
        /// </summary>
        public bool showSubUserDepth;

        /// <summary>
        /// 是否计算关节点四元数.
        /// </summary>
        public bool isNeedJointsOri;
        /// <summary>
        /// 是否计算关节点速度.
        /// </summary>
        public bool isNeedJointsSpeed;
        /// <summary>
        /// 是否计算关节点向量速度.
        /// </summary>
        public bool isNeedVecSpeed;

        private static object _lock = new object();
        public static ImiPreferences GetInstance()
        {
            if (instance == null)
            {
                lock (_lock)
                {
                    if (instance == null)
                    {
                        instance = new ImiPreferences();
                    }
                }
            }
            return instance;
        }

        private ImiPreferences()
        {
            Reset();
        }

        /// <summary>
        /// Clear All Preferences
        /// </summary>
        public void Reset()
        {
            depthResolution = new ImiResolution();
            colorResolution = new ImiResolution();
            DepthStream = false;
            SkeletonStream = false;
            DepthSkeletonStream = false;
            UserDepthAndSkeletonStream = true;
            ColorStream = false;

            showMainUserColor = false;
            showSubUserColor = false;
            showAllUsersDepth = false;
            showMainUserDepth = false;
            showSubUserDepth = false;
            showDepthOnly = false;
            showAllUsersColor = false;

            isNeedJointsOri = false;
            isNeedJointsSpeed = true;
            isNeedVecSpeed = true;

        }


        public int GetDepthWidth()
        {
            return depthResolution.Width;
        }
        
        public int GetDepthHeight()
        {
            return depthResolution.Height;
        }

        public int GetColorWidth()
        {
            return colorResolution.Width;
        }

        public int GetColorHeight()
        {
            return colorResolution.Height;
        }

        public int GetDepthMapSize()
        {
            return depthResolution.Size;
        }
        public int GetColorImageSize()
        {
            return colorResolution.Size;
        }
    }
}